import request from '@/utils/request'
import {parseStrEmpty} from "@/utils/ruoyi.js";
import {makeFormDataOptions} from "@/utils/hazard.js";

export function listHazard(query) {
    return request({
        url: '/hazard/getHazardList',
        method: 'get',
        params: query
    })
}

// 查询文件详细
// export function getHazard(id) {
//     return request({
//         url: '/hazard/' + parseStrEmpty(id),
//         method: 'get'
//     })
// }

// 新增文件
export function addHazard(data) {
    return request({
        url: '/hazard/addHazard',
        method: 'post',
        data: data
    })
}

// 修改文件
export function updateHazard(data) {
    return request({
        url: '/hazard/editHazard',
        method: 'put',
        data: data
    })
}

// 删除文件
export function delHazard(id) {
    return request({
        url: '/hazard/deleteHazard',
        method: 'post',
        data: (id + '').split(',')
    })
}


// 督办完成
export function superviseHazard(id, finishDate) {
    return request({
        url: '/hazard/superviseHazard/' + id,
        method: 'put',
        ...makeFormDataOptions({finishDate})
    })
}

// 整改完成
export function finishHazard(id, finishDate) {
    return request({
        url: '/hazard/finishHazard/' + id,
        method: 'put',
        ...makeFormDataOptions({finishDate})
    })
}

// dashboard
export function getHazardDashboard() {
    return request({
        url: '/hazard/getHazardDashboard',
        method: 'post'
    })
}
// alarm
export function getHazardAlarm(data) {
    return request({
        url: '/hazard/getHazardAlarm',
        method: 'post',
        ...makeFormDataOptions(data)
    })
}
// hazard type stat
export function getHazardTypeStatistics(data) {
    return request({
        url: '/hazard/getHazardTypeStatistics',
        method: 'post',
        ...makeFormDataOptions(data)
    })
}
// hazard level stat
export function getHazardLevelStatistics(data) {
    return request({
        url: '/hazard/getHazardLevelStatistics',
        method: 'post',
        ...makeFormDataOptions(data)
    })
}